Skip to content
This repository was archived by the owner on Apr 2, 2024. It is now read-only.

Switch to first-class aggregate support in pgx #62

Draft
wants to merge 3 commits into
base: develop
Choose a base branch
from

Conversation

JamesGuthrie
Copy link
Member

Note this is a WIP, and removes backwards-compatibility functions.

Part of #61

@JamesGuthrie JamesGuthrie force-pushed the jg/first-class-aggs-2 branch 4 times, most recently from 13f1301 to 7e25a80 Compare January 14, 2022 15:40
#[pg_aggregate]
impl Aggregate for PromIncrease {
type State = Option<GapfillDeltaTransition>;
type Args = (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's unfortunate that this trait requires an extra allocation just to pack the arguments into a tuple in order to call the state function, but I guess that was a tradeoff they were forced to make. I wonder what the impact of that is in a hot aggregate.

Copy link
Contributor

@bitwalker bitwalker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Definitely cleaner! I think we'll want to try and benchmark the overhead of wrapping arguments in a tuple, since I could see that potentially being an issue in hot aggregates, but we'll have to concoct a decent benchmark setup for that (we probably should be thinking about that anyway, especially with performance being one of our main objectives this year).

Rust does have facilities for that, but we may have to upstream some support in pgx for it, since it would need to build on top of the pgx infra, just like how testing does.

@JamesGuthrie JamesGuthrie force-pushed the jg/first-class-aggs-2 branch 5 times, most recently from 2c75f82 to 496c7d6 Compare January 20, 2022 08:45
@JamesGuthrie JamesGuthrie self-assigned this Jan 20, 2022
@JamesGuthrie JamesGuthrie force-pushed the jg/first-class-aggs-2 branch 4 times, most recently from 0143dc8 to 73025eb Compare January 31, 2022 07:41
`#[pgx(sql = false)]` suppresses SQL generation for this object, so the
generated SQL is incomplete. We will use this SQL-suppression, but it's
missing some pieces which still need to be developed.
- Pgx automatically handles in_aggregate_context, so we can remove some
  (now) unused code.
- Because vector_selector's state type is no longer INTERNAL, we don't
  need to provide (de)serialization functions.
- We have removed backwards-compatibility wrappers for aggregates.
@sumerman sumerman mentioned this pull request Jan 9, 2023
2 tasks
@cevian cevian removed their request for review July 6, 2023 23:49
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants